package per.jdz.demo.readlistener;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.read.listener.ReadListener;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Jdz
 * @date 2025/2/5
 */
@Data
@Slf4j
public class AbstractListener <T> implements ReadListener<T> {
    protected  final Integer BATCH_SIZE = 1000;
    protected  String outputFileNamePrefix ;
    protected  String outputFileNameSuffix;
    protected  String splitSavePath;
    // 创建一个计数器来跟踪已处理的行数
    protected  final AtomicInteger rowCounter = new AtomicInteger(0);
    // 创建一个计数器来跟踪文件的数量
    protected  final AtomicInteger fileCounter = new AtomicInteger(0);
    // 用于保存当前批次的数据
    protected  final List<T> currentBatch = Collections.synchronizedList(new ArrayList<>(BATCH_SIZE));

    public AbstractListener(String outputFileNamePrefix, String outputFileNameSuffix, String splitSavePath) {
        this.outputFileNamePrefix = outputFileNamePrefix;
        this.outputFileNameSuffix = outputFileNameSuffix;
        this.splitSavePath = splitSavePath;
    }


    @Override
    public void invoke(T t, AnalysisContext analysisContext) {

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
